﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace FooFun.DataElements.Dtos
{
    public class CustomDataElement : DataElement
    {
        IDataElement de;

        public IDataElement InnerDataElement
        {
            get { return de; }
            set { de = value; }
        }

        public CustomDataElement(IDataElement de)
        {
            this.InnerDataElement = de;
        }

        #region Object成员
        public override bool Equals(object obj)
        {
            return de.Equals(obj);
        }

        public override string ToString()
        {
            return de.ToString();
        }

        public override int GetHashCode()
        {
            return de.GetHashCode();
        }

        #endregion

        #region IDataElement 成员

        public override IEnumerable GetKeys()
        {
            return de.GetKeys();
        }

        public override IDataElement this[int index]
        {
            get
            {
                return de[index];
            }
            set
            {
                de[index] = value;
            }
        }

        public override object Value
        {
            get
            {
                return de.Value;
            }
            set
            {
                de.Value = value;
            }
        }

        public override IDataElement this[string attrName]
        {
            get
            {
                return this.de[attrName];
            }
            set
            {
                de[attrName] = value;
            }
        }

        public override IDataElement Add(IDataElement de)
        {
            return ((XmlElementDataElement)this.de).Add(de);
        }

        public override bool IsEmpty
        {
            get
            {
                return this.de.IsEmpty;
            }
        }

        public override IDataElement Parent
        {
            get
            {
                return de.Parent;
            }
            set
            {
                de.Parent = value;
            }
        }

        #endregion

        #region IEnumerable 成员

        public override IEnumerator GetEnumerator()
        {
            foreach (IDataElement o in this.de)
            {
                yield return o;
            }
        }

        #endregion
    }
}
